﻿using RepositoryDefinition;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ForumBL
{
    public class CategoryBL
    {
        ICategoryRepository categoryContext;
        IPostRepository postContext;

        public CategoryBL()
        {
            categoryContext = IOC.Factory.GetRepository().GetCategoryRepository();
            postContext = IOC.Factory.GetRepository().GetPostRepository();
        }


        public List<ForumDomainModels.Category> GetCategoriesBySection(ForumDomainModels.Section section)
        {
            List<ForumDomainModels.Category> categories = categoryContext.GetCategoriesBySection(section);
            return categories;
        }

        public DateTime LastPostTimeInCategory(ForumDomainModels.Category category)
        {   
            DateTime timeOfLatestPost = postContext.GetTimeOfLatestPostByCategory(category);
            return timeOfLatestPost;
        }

        public ForumDomainModels.Category GetCategoryById(ForumDomainModels.Category category)
        {
            ForumDomainModels.Category retrievedCategory = categoryContext.GetCategoryById(category);
            return retrievedCategory;
        }
    }
}
